/*
 * Annotation container
 */
YAHOO.dasBrowser.genome.karyotypeStructure.karyotype.drawAnnotations = function(myAnnotationFeature, myAnnotationSegment, selectedType, chrId, chrPrefix, sourceArrayNumber){
	//if (YAHOO.dasBrowser.genome.annotations.showSimpleView) {
	if(myAnnotationFeature.length != 0 && myAnnotationSegment != null){	
		/*
		 * Set variables
		 */
		var bandLabelPrefix = YAHOO.dasBrowser.genome.karyotypeStructure.karyotype.bandConf.labelPrefix;
		var chromosomeLabelPrefix = YAHOO.dasBrowser.genome.karyotypeStructure.karyotype.chromosomeConf.labelPrefix;
		var zoomLabelPrefix = YAHOO.dasBrowser.genome.karyotypeStructure.karyotype.zoomConf.labelPrefix;
		var sourcePanel = YAHOO.dasBrowser.genome.annotations.sources[sourceArrayNumber].panel;
		var annotationSource = YAHOO.dasBrowser.genome.annotations.sources[sourceArrayNumber];
		var positional = myAnnotationSegment.positional;
		var nonPositional = myAnnotationSegment.nonPositional;
		var annotationPaddingBottom = YAHOO.dasBrowser.genome.annotations.simpleView.annotationPaddingBottom;
		var annotationLimitDisplay = YAHOO.dasBrowser.genome.karyotypeStructure.karyotype.karyotypeConf.annotationLimitDisplay;
		/*
		 * Set chromosome height
		 */
		if(chrPrefix == YAHOO.dasBrowser.genome.karyotypeStructure.karyotype.karyotypeConf.labelPrefix){
			var chromosomeHeight = YAHOO.dasBrowser.genome.karyotypeStructure.karyotype.karyotypeConf.chromosomeHeightPx;
		}else if (chrPrefix == YAHOO.dasBrowser.genome.karyotypeStructure.karyotype.chromosomeConf.labelPrefix){
			var chromosomeHeight = YAHOO.dasBrowser.genome.karyotypeStructure.karyotype.chromosomeConf.chromosomeHeightPx;
		}else if (chrPrefix == YAHOO.dasBrowser.genome.karyotypeStructure.karyotype.zoomConf.labelPrefix){
			var chromosomeHeight = YAHOO.dasBrowser.genome.karyotypeStructure.karyotype.zoomConf.heightPx;
		}else{
			var chromosomeHeight = YAHOO.dasBrowser.genome.karyotypeStructure.karyotype.karyotypeConf.bandHeightPx;
		}
		
		/*
		 * Set annotation height and margins
		 */
		var chromosomeContainerPrefix = YAHOO.dasBrowser.genome.karyotypeStructure.karyotype.panelContainer.chromosomeContainer.labelPrefix;
		var chromosomeRepresentationContainerPrefix = YAHOO.dasBrowser.genome.karyotypeStructure.karyotype.panelContainer.chromosomeContainer.chromosomeRepresentationContainer.labelPrefix;
		if (annotationSource.representation == 'mark' || annotationSource.representation == 'track') {
			var simpleAnnotationContainerPosition = YAHOO.dasBrowser.genome.karyotypeStructure.karyotype.panelContainer.chromosomeContainer.bottomSimpleAnnotationContainer.positionPrefix;
			var simpleAnnotationContainerPrefix = YAHOO.dasBrowser.genome.karyotypeStructure.karyotype.panelContainer.chromosomeContainer.bottomSimpleAnnotationContainer.labelPrefix;
			if (chrPrefix == bandLabelPrefix) {
				var annotationHeight = YAHOO.dasBrowser.genome.karyotypeStructure.karyotype.panelContainer.chromosomeContainer.bottomSimpleAnnotationContainer.height_Bv;
			}else if (chrPrefix == chromosomeLabelPrefix) {
				var annotationHeight = YAHOO.dasBrowser.genome.karyotypeStructure.karyotype.panelContainer.chromosomeContainer.bottomSimpleAnnotationContainer.height_Cv;
			}else if (chrPrefix == zoomLabelPrefix) {
				var annotationHeight = YAHOO.dasBrowser.genome.karyotypeStructure.karyotype.panelContainer.chromosomeContainer.bottomSimpleAnnotationContainer.height_Zv;
			} else {
				var annotationHeight = YAHOO.dasBrowser.genome.karyotypeStructure.karyotype.panelContainer.chromosomeContainer.bottomSimpleAnnotationContainer.height_Kv;
			}
			//marginTop = '2px';
			marginTop = '7px';
			marginBottom = '2px';
		} else if (annotationSource.representation== "chart" || annotationSource.representation == "line") {
			var simpleAnnotationContainerPosition = YAHOO.dasBrowser.genome.karyotypeStructure.karyotype.panelContainer.chromosomeContainer.topSimpleChartAnnotationContainer.positionPrefix;
			var simpleAnnotationContainerPrefix = YAHOO.dasBrowser.genome.karyotypeStructure.karyotype.panelContainer.chromosomeContainer.topSimpleChartAnnotationContainer.labelPrefix;
			if (chrPrefix == bandLabelPrefix) {
				var annotationHeight = YAHOO.dasBrowser.genome.karyotypeStructure.karyotype.panelContainer.chromosomeContainer.topSimpleChartAnnotationContainer.height_Bv;
			}else if (chrPrefix == chromosomeLabelPrefix) {
				var annotationHeight = YAHOO.dasBrowser.genome.karyotypeStructure.karyotype.panelContainer.chromosomeContainer.topSimpleChartAnnotationContainer.height_Cv;
			}else if (chrPrefix == zoomLabelPrefix) {
				var annotationHeight = YAHOO.dasBrowser.genome.karyotypeStructure.karyotype.panelContainer.chromosomeContainer.topSimpleChartAnnotationContainer.height_Zv;
			} else {
				var annotationHeight = YAHOO.dasBrowser.genome.karyotypeStructure.karyotype.panelContainer.chromosomeContainer.topSimpleChartAnnotationContainer.height_Kv;
			}
			marginTop = '8px';
			marginBottom = '4px';		
		}
		
		
		/*
		 * Set prefix and names for containers
		 */
		var chrContainerName = chrPrefix + chromosomeContainerPrefix + chromosomeRepresentationContainerPrefix;
		var simpleViewContainerName = chrPrefix + chromosomeContainerPrefix + simpleAnnotationContainerPosition + simpleAnnotationContainerPrefix;
		var simpleViewSourceContainerName = chrPrefix + chromosomeContainerPrefix + simpleAnnotationContainerPrefix;
		
		/*
		 * Get width from the chromosome
		 */
		var eChrContainer = new YAHOO.util.Element(chrContainerName +'_' + chrId);
		chrContainerWidthStyle = eChrContainer.getStyle('width');
		var widthPx = YAHOO.dasBrowser.util.deletePxSuffix(chrContainerWidthStyle);	
		
		/*
		 * Define annotation source container
		 */
		var simpleViewSourceContainer = document.createElement("div");
		var eSimpleViewSourceContainer = new YAHOO.util.Element(simpleViewSourceContainer);
		eSimpleViewSourceContainer.set('id', simpleViewSourceContainerName + '_' + chrId  + '_s' + sourceArrayNumber);
		eSimpleViewSourceContainer.setStyle('position', 'relative');
		eSimpleViewSourceContainer.setStyle('width', chrContainerWidthStyle);
		eSimpleViewSourceContainer.setStyle('margin-top', marginTop);
		eSimpleViewSourceContainer.setStyle('margin-bottom', marginBottom);
		
		/*
		 * Just for MARK and TRACK
		 */
		var sourceLabelsHeight = 0;
		if(annotationSource.representation == 'mark' || annotationSource.representation == 'track'){
			/*
			 * Display a bottom border line to separete sources.
		 	 */
			eSimpleViewSourceContainer.setStyle('border-top', '1px dotted #999999');
			eSimpleViewSourceContainer.setStyle('border-bottom', '1px dotted #999999');
			//eSimpleViewSourceContainer.setStyle('background-color', '#f2f2f2'); // grey, too dark!
			//eSimpleViewSourceContainer.setStyle('background-color', '#F8F8F8'); // grey, OK!
			//eSimpleViewSourceContainer.setStyle('background-color', '#F8F8FF'); // blue
			eSimpleViewSourceContainer.setStyle('background-color', '#FBFBFF');
			//eSimpleViewSourceContainer.setStyle('z-index', '-1');
			/*
			 * Set label container on the ZOOM and BAND view
		 	 */
			if(chrPrefix == bandLabelPrefix || chrPrefix == zoomLabelPrefix){
				//sourceLabelsHeight = 7;
				sourceLabelsHeight = 2;
				var simpleViewSourceContainerLabels = document.createElement("div");
				var eSimpleViewSourceContainerLabels = new YAHOO.util.Element(simpleViewSourceContainerLabels);
				eSimpleViewSourceContainerLabels.set('id', simpleViewSourceContainerName + '_' + chrId  + '_s' + sourceArrayNumber + '_labels');
				eSimpleViewSourceContainerLabels.setStyle('position', 'relative');
				eSimpleViewSourceContainerLabels.setStyle('width', chrContainerWidthStyle);
				eSimpleViewSourceContainerLabels.setStyle('top', YAHOO.dasBrowser.util.addPxSuffix(annotationHeight-1));
				//eSimpleViewSourceContainerLabels.setStyle('margin-bottom', marginBottom);
				eSimpleViewSourceContainerLabels.setStyle('height', YAHOO.dasBrowser.util.addPxSuffix(sourceLabelsHeight));
				eSimpleViewSourceContainer.appendChild(eSimpleViewSourceContainerLabels);
			}
		}
		
		/*
		 * Annotation source container height
		 */
		eSimpleViewSourceContainer.setStyle('height', YAHOO.dasBrowser.util.addPxSuffix(annotationHeight+sourceLabelsHeight));
		
		/*
		 * Hide anotations on the Karyotype View if there are more than 500
		 */
		if(positional > annotationLimitDisplay && chrPrefix == 'Kv'){
			eSimpleViewSourceContainer.setStyle('display', 'none');
		} else {
			eSimpleViewSourceContainer.setStyle('display', 'block');
		}
		
		/*
		 * Annotation source container background. Just for CHART and LINE representations
		 */
		if(annotationSource.representation == "chart" || annotationSource.representation == "line"){
			topBgLine = annotationHeight*0;
			middleBgLine = annotationHeight/2;
			bottomBgLine = annotationHeight;
			
			var simpleViewSourceContainerTopBgLine = document.createElement("div");
			var eSimpleViewSourceContainerTopBgLine = new YAHOO.util.Element(simpleViewSourceContainerTopBgLine);
			eSimpleViewSourceContainerTopBgLine.set('id', simpleViewSourceContainerName + '_' + chrId  + '_s' + sourceArrayNumber + 'topBgLine');
			eSimpleViewSourceContainerTopBgLine.setStyle('border-bottom', '1px dotted #999999');
			eSimpleViewSourceContainerTopBgLine.setStyle('width', chrContainerWidthStyle);
			eSimpleViewSourceContainerTopBgLine.setStyle('position', 'absolute');
			//eSimpleViewSourceContainerTopBgLine.setStyle('top', '0px');
			eSimpleViewSourceContainerTopBgLine.setStyle('top', YAHOO.dasBrowser.util.addPxSuffix(topBgLine));
			eSimpleViewSourceContainer.appendChild(eSimpleViewSourceContainerTopBgLine);
			
			var simpleViewSourceContainerMiddleBgLine = document.createElement("div");
			var eSimpleViewSourceContainerMiddleBgLine = new YAHOO.util.Element(simpleViewSourceContainerMiddleBgLine);
			eSimpleViewSourceContainerMiddleBgLine.set('id', simpleViewSourceContainerName + '_' + chrId  + '_s' + sourceArrayNumber + 'middleBgLine');
			eSimpleViewSourceContainerMiddleBgLine.setStyle('border-bottom', '1px dashed #999999');
			eSimpleViewSourceContainerMiddleBgLine.setStyle('width', chrContainerWidthStyle);
			eSimpleViewSourceContainerMiddleBgLine.setStyle('position', 'absolute');
			//eSimpleViewSourceContainerMiddleBgLine.setStyle('top', '0px');
			eSimpleViewSourceContainerMiddleBgLine.setStyle('top', YAHOO.dasBrowser.util.addPxSuffix(middleBgLine));
			eSimpleViewSourceContainer.appendChild(eSimpleViewSourceContainerMiddleBgLine);
			
			var simpleViewSourceContainerBottomBgLine = document.createElement("div");
			var eSimpleViewSourceContainerBottomBgLine = new YAHOO.util.Element(simpleViewSourceContainerBottomBgLine);
			eSimpleViewSourceContainerBottomBgLine.set('id', simpleViewSourceContainerName + '_' + chrId  + '_s' + sourceArrayNumber + 'bottomBgLine');
			eSimpleViewSourceContainerBottomBgLine.setStyle('border-bottom', '1px solid #666666');
			eSimpleViewSourceContainerBottomBgLine.setStyle('width', chrContainerWidthStyle);
			eSimpleViewSourceContainerBottomBgLine.setStyle('position', 'absolute');
			//eSimpleViewSourceContainerBottomBgLine.setStyle('top', '0px');
			eSimpleViewSourceContainerBottomBgLine.setStyle('top', YAHOO.dasBrowser.util.addPxSuffix(bottomBgLine));
			eSimpleViewSourceContainer.appendChild(eSimpleViewSourceContainerBottomBgLine);
			
			var imageBgHeight = 32;
			var simpleViewSourceContainerBg = document.createElement("div");
			var eSimpleViewSourceContainerBg = new YAHOO.util.Element(simpleViewSourceContainerBg);
			eSimpleViewSourceContainerBg.set('id', simpleViewSourceContainerName + '_' + chrId  + '_s' + sourceArrayNumber + 'bg');
			eSimpleViewSourceContainerBg.setStyle('width', chrContainerWidthStyle);
			eSimpleViewSourceContainerBg.setStyle('position', 'absolute');
			eSimpleViewSourceContainerBg.setStyle('background-image', 'url(img/chart_bg.gif)');
			eSimpleViewSourceContainerBg.setStyle('height', YAHOO.dasBrowser.util.addPxSuffix(imageBgHeight));
			//eSimpleViewSourceContainerBg.setStyle('top', '0px');
			eSimpleViewSourceContainerBg.setStyle('top', YAHOO.dasBrowser.util.addPxSuffix(bottomBgLine-imageBgHeight));
			eSimpleViewSourceContainerBg.setStyle('z-index', '-1');
			eSimpleViewSourceContainerBg.setStyle('opacity', 0.7);
			eSimpleViewSourceContainer.appendChild(eSimpleViewSourceContainerBg);
		}
		
		
		/*
		 * Source label on the right of the sources
		 */
		if (chrPrefix != 'Kv') {
			var simpleViewSourceContainerSourceLabel = document.createElement("div");
			var eSimpleViewSourceContainerSourceLabel = new YAHOO.util.Element(simpleViewSourceContainerSourceLabel);
			eSimpleViewSourceContainerSourceLabel.setStyle('position', 'absolute');
			eSimpleViewSourceContainerSourceLabel.setStyle('top', '-10px');
			//eSimpleViewSourceContainerSourceLabel.setStyle('top', '-5px');
			//eSimpleViewSourceContainerSourceLabel.setStyle('left', chrContainerWidthStyle);
			eSimpleViewSourceContainerSourceLabel.addClass('fontSize9');
			eSimpleViewSourceContainerSourceLabel.setStyle('color', '#999999');
			eSimpleViewSourceContainerSourceLabel.appendChild(document.createTextNode(annotationSource.name));
			eSimpleViewSourceContainer.appendChild(eSimpleViewSourceContainerSourceLabel);
		}
		
		
	/*	
		eScoreContainer.setStyle('position', 'absolute');
	eScoreContainer.addClass('fontSize10');
	eScoreContainer.setStyle('top', '-6px');
	eScoreContainer.setStyle('left', '-40px');
	eScoreContainer.setStyle('width', '36px');
	eScoreContainer.setStyle('text-align', 'right');
	//eScoreContainer.setStyle('background-color', '#00FF00');
	//eHighestScore.setStyle('top', YAHOO.dasBrowser.util.addPxSuffix(topBgLine));
	eScoreContainer.appendChild(document.createTextNode(value));
	*/
		
		
		
		
		/*
		 * Append Source container
		 */
		var eSimpleViewContainer = new YAHOO.util.Element(simpleViewContainerName +'_' + chrId);
		eSimpleViewContainer.appendChild(eSimpleViewSourceContainer);

		
		/*
		 * Different reference numbers for chart and line. On chart the loswest value is the middle of the chart
		 */
		if (annotationSource.representation == "chart") {
			var highestScore = YAHOO.dasBrowser.genome.annotations.sources[sourceArrayNumber].highestScore;
			var lowestScore = YAHOO.dasBrowser.genome.annotations.sources[sourceArrayNumber].lowestScore;
			var middleScore = highestScore - ((highestScore - lowestScore)/2);
			if (highestScore < 0) { var scoreDecimal = 3 } else { var scoreDecimal = 1 }
			drawScoreReference(highestScore.toFixed(scoreDecimal), simpleViewSourceContainerName + '_' + chrId + '_s' + sourceArrayNumber + 'topBgLine', '#666666');
			drawScoreReference(middleScore.toFixed(scoreDecimal), simpleViewSourceContainerName + '_' + chrId + '_s' + sourceArrayNumber + 'middleBgLine', '#666666');
			drawScoreReference(lowestScore.toFixed(scoreDecimal), simpleViewSourceContainerName + '_' + chrId + '_s' + sourceArrayNumber + 'bottomBgLine', '#CCCCCC');		
		} else if (annotationSource.representation == "line"){
			var highestScore = YAHOO.dasBrowser.genome.annotations.sources[sourceArrayNumber].highestScore;
			var lowestScore = highestScore - ((highestScore - YAHOO.dasBrowser.genome.annotations.sources[sourceArrayNumber].lowestScore)/2);
			var middleScore = highestScore - ((highestScore - lowestScore)/2);
			if (highestScore < 0) { var scoreDecimal = 3 } else { var scoreDecimal = 1 }
			drawScoreReference(highestScore.toFixed(scoreDecimal), simpleViewSourceContainerName + '_' + chrId + '_s' + sourceArrayNumber + 'topBgLine', '#666666');
			drawScoreReference(middleScore.toFixed(scoreDecimal), simpleViewSourceContainerName + '_' + chrId + '_s' + sourceArrayNumber + 'middleBgLine', '#666666');
			drawScoreReference(lowestScore.toFixed(scoreDecimal), simpleViewSourceContainerName + '_' + chrId + '_s' + sourceArrayNumber + 'bottomBgLine', '#CCCCCC');		
		}
	
		/*
		 * Create referenceSeq object with START and END positions
		 */
		if (chrPrefix == YAHOO.dasBrowser.genome.karyotypeStructure.karyotype.bandConf.labelPrefix) {
			var selectedBandId = YAHOO.dasBrowser.genome.karyotypeStructure.karyotype.bandConf.selectedBand;
			var selectedBandObject = YAHOO.dasBrowser.genome.karyotypeStructure.karyotype.chromosomes[chrId].bands[selectedBandId];
			var referenceSeq = new Object();
			referenceSeq.start = selectedBandObject.start;
			referenceSeq.end = selectedBandObject.end;
		} else if (chrPrefix == YAHOO.dasBrowser.genome.karyotypeStructure.karyotype.zoomConf.labelPrefix) {
			var selectedEntryPoint = YAHOO.dasBrowser.genome.karyotypeStructure.entryPoints.allEntryPoints[chrId];
			var referenceSeq = new Object();
			referenceSeq.start = parseInt(YAHOO.dasBrowser.genome.karyotypeStructure.karyotype.zoomConf.start);
			referenceSeq.end = parseInt(YAHOO.dasBrowser.genome.karyotypeStructure.karyotype.zoomConf.stop);
		} else {
			var selectedEntryPoint = YAHOO.dasBrowser.genome.karyotypeStructure.entryPoints.allEntryPoints[chrId];
			var referenceSeq = new Object();
			referenceSeq.start = selectedEntryPoint.start;
			referenceSeq.end = selectedEntryPoint.stop;
		}

		/*
		 * Draw all the annotations (from one Source and one Chromosome)
		 */
		var labelPrefix = simpleViewSourceContainerName + '_' + chrId  + '_s' + sourceArrayNumber;
		var drawAnnotation = true;
		var featureNumber = 0;
		var annotsFeatureCoordinates = new Object();
		var annots = new Object();
		var annot = new Array();
		
		for (var j = 0; j < myAnnotationFeature.length; j++) {
			annot = new Array();
			/*
			 * Chose just annotation inside the visualization region
		 	 */
			var featureOnReference = frameAnnotation(
				referenceSeq.start, 
				referenceSeq.end,
				myAnnotationFeature[j].start,
				myAnnotationFeature[j].end
			);
			
			if (featureOnReference.visible) {
				featureNumber++;
				/*
			 	 * Create object with pixel positional information
		 	 	 */
				var featureCoordinates = new myFeaturePosition();
				featureCoordinates.setReferenceLengthPx(widthPx);
				featureCoordinates.setFeatureStartSeq(featureOnReference.start);
				featureCoordinates.setFeatureEndSeq(featureOnReference.end);
				featureCoordinates.setReferenceStartSeq(featureOnReference.refStart);
				featureCoordinates.setReferenceEndSeq(featureOnReference.refEnd);
				featureCoordinates.calculatePx();
				
				/*
		 		 * Get input (list of annotations) to calculate overlaping features
				 */
				if (annotationSource.representation == 'track') {
					featureCoordinates.featureStartPx
					if(featureCoordinates.featureLengthPx < 1){
						var featureLengthPx = 1;
					} else {
						var featureLengthPx = featureCoordinates.featureLengthPx;
					}
					annot[0] = featureCoordinates.featureStartPx;
					annot[1] = featureCoordinates.featureStartPx+featureLengthPx;
					annots[j] = annot;
					annotsFeatureCoordinates[j] = featureCoordinates;
				}
				
				/*
		 		 * Send draw request for MARK, CHART and LINE representation
				 */
				if (annotationSource.representation == 'mark') {
					if (selectedType == null) {
						YAHOO.dasBrowser.genome.karyotypeStructure.karyotype.drawChromosomeSimpleAnnotation(myAnnotationFeature[j], chrId, labelPrefix, chrPrefix, sourceArrayNumber, featureCoordinates, annotationHeight);
					}
				}
				else if (annotationSource.representation == "chart") {
					if (selectedType == null) {
						YAHOO.dasBrowser.genome.karyotypeStructure.karyotype.drawChromosomeSimpleAnnotationChart(myAnnotationFeature[j], chrId, labelPrefix, chrPrefix, sourceArrayNumber, featureCoordinates, annotationHeight);
					}
				} else if (annotationSource.representation == "line") {
					if (selectedType == null) {
						YAHOO.dasBrowser.genome.karyotypeStructure.karyotype.drawChromosomeSimpleAnnotationChart(myAnnotationFeature[j], chrId, labelPrefix, chrPrefix, sourceArrayNumber, featureCoordinates, annotationHeight);
					}
				}  // if annotationSource.representation == 'mark'
			}
		}
		
		//console.log(annotationSource.representation);

		/*
		 * Send draw request for TRACK representation
		 */
		if (annotationSource.representation == 'track') {
			if (selectedType == null) {
				for (var j in annots) {
					//console.log(trackAnnot[j]);
				}
				var countTracks=0;
				var aOverlaping = new annotationOverlaping();
				aOverlaping.setAnnot(annots);
				aOverlaping.run();
				for (var i = 0; i < aOverlaping.tracks.length; i++) {
					//console.log("track: " + i);
					countTracks++;
					//featureCoordinates.setTrack(i);
					for (var j in aOverlaping.tracks[i]){
						annotsFeatureCoordinates[j].setTrack(i);
						//console.log(aOverlaping.tracks[i][j][0] + " " + aOverlaping.tracks[i][j][1]);
						YAHOO.dasBrowser.genome.karyotypeStructure.karyotype.drawChromosomeSimpleAnnotation(myAnnotationFeature[j], chrId, labelPrefix, chrPrefix, sourceArrayNumber, annotsFeatureCoordinates[j], annotationHeight);
					}
				}
				var eAnnotSourceContainer = new YAHOO.util.Element(labelPrefix);
				var eAnnotSourceContainer_height = YAHOO.dasBrowser.util.deletePxSuffix(eAnnotSourceContainer.getStyle('height'));
				var eAnnotSourceContainer_newHeight = YAHOO.dasBrowser.util.addPxSuffix(eAnnotSourceContainer_height*countTracks);
				eAnnotSourceContainer.setStyle('height', eAnnotSourceContainer_newHeight);
			}
		}
		
		/*
		 * Set the number of features per Band and Zoom
		 */
		if (chrPrefix == YAHOO.dasBrowser.genome.karyotypeStructure.karyotype.bandConf.labelPrefix) {
			YAHOO.dasBrowser.genome.karyotypeStructure.karyotype.bandConf.featureNumber = featureNumber;
		} else if (chrPrefix == YAHOO.dasBrowser.genome.karyotypeStructure.karyotype.zoomConf.labelPrefix) {
			YAHOO.dasBrowser.genome.karyotypeStructure.karyotype.zoomConf.featureNumber = featureNumber;
		}
	}
}

	

function drawScoreReference(value, divTarget, color){
	var eDivTarget = new YAHOO.util.Element(divTarget);
	//('id', simpleViewSourceContainerName + '_' + chrId  + '_s' + sourceArrayNumber + 'middleBgLine');
	var highestScoreValue = 50;
	var scoreContainer = document.createElement("span");
	var eScoreContainer = new YAHOO.util.Element(scoreContainer);
	//eHighestScore.setStyle('border-bottom', '1px dashed #999999');
	eScoreContainer.setStyle('color', color);
	eScoreContainer.setStyle('position', 'absolute');
	eScoreContainer.addClass('fontSize10');
	eScoreContainer.setStyle('top', '-6px');
	eScoreContainer.setStyle('left', '-40px');
	eScoreContainer.setStyle('width', '36px');
	eScoreContainer.setStyle('text-align', 'right');
	//eScoreContainer.setStyle('background-color', '#00FF00');
	//eHighestScore.setStyle('top', YAHOO.dasBrowser.util.addPxSuffix(topBgLine));
	eScoreContainer.appendChild(document.createTextNode(value));
	eDivTarget.appendChild(eScoreContainer);
}



/*
 * Calculate new positional values and set visible if the annotation is inside the selected region
 */
function frameAnnotation(refStart, refEnd, featStart, featEnd){
	var correction = parseInt(refStart) -1;
	var refStart = parseInt(refStart)-correction;
	var refEnd = parseInt(refEnd)-correction;
	var featStart = parseInt(featStart)-correction;
	var featEnd = parseInt(featEnd)-correction;
	
	var test1 = false;
	var test2 = false;
	var feature = {
		visible: false,
		//startResized: false,
		//endResized: false,
		start: featStart,
		end: featEnd,
		refStart: refStart,
		refEnd: refEnd
	}
	
	if(featEnd > refStart){test1 = true;}
	if(featStart < refEnd){test2 = true;}
	if(test1 && test2){
		feature.visible = true;
		if(featEnd > refEnd){
			feature.end = refEnd;
		}
		if(featStart < refStart){
			feature.start = refStart;
		}
	}
	return feature;
}



YAHOO.dasBrowser.genome.karyotypeStructure.karyotype.drawChromosomeSimpleAnnotationChart = function(feature, chrId, labelPrefix, chrPrefix, sourceArrayNumber, featureCoordinates, annotationHeight){
	var chartHighestScore = YAHOO.dasBrowser.genome.annotations.sources[sourceArrayNumber].highestScore;
	var chartLowestScore = YAHOO.dasBrowser.genome.annotations.sources[sourceArrayNumber].lowestScore;
	var diferenceScore = chartHighestScore - chartLowestScore;
	var featureScore = (feature.score - chartLowestScore)/diferenceScore;
	var annotationSource = YAHOO.dasBrowser.genome.annotations.sources[sourceArrayNumber];
	
	if(annotationSource.representation == "line"){
		if (annotationSource.align == "top") {
			var annotationHeight = annotationHeight*2;
		} else {
			//var annotationHeight = annotationHeight*2;
		}
	}
		
	var annotationContainerHeight = annotationHeight;

	var arrowLimitPx = YAHOO.dasBrowser.genome.annotations.simpleView.arrowLimitPx;
	
	//Scale SCORES to 0-1.
	
	
	var annotationHeight = Math.round(annotationContainerHeight * parseFloat(featureScore));
	//if(annotationSource.representation == "line"){
		//var annotationTop = annotationContainerHeight - annotationHeight;
	//} else {
		if (annotationSource.align == "top") {
			var annotationTop = annotationContainerHeight - annotationHeight;
		} else {
			var annotationTop = -1;
		}
	//}

	/*
	 * Get WIDTH for the chromosome container
	 */
	var eChrContainer = new YAHOO.util.Element(labelPrefix);
	var eChrContainerWidthStyle = eChrContainer.getStyle('width');
	var widthPx = YAHOO.dasBrowser.util.deletePxSuffix(eChrContainerWidthStyle);
	//CvContSAnnot_chromosome1_s0

/*
	var featureCoordinates = new myFeaturePosition();
	featureCoordinates.setReferenceLengthPx(widthPx);
	featureCoordinates.setFeatureStartSeq(featureOnReference.start);
	featureCoordinates.setFeatureEndSeq(featureOnReference.end);
	featureCoordinates.setReferenceStartSeq(featureOnReference.refStart);
	featureCoordinates.setReferenceEndSeq(featureOnReference.refEnd);
	featureCoordinates.calculatePx();
*/	
		
	if(featureCoordinates.featureLengthPx < 1){
		var featureLengthPx = 1;
	} else {
		var featureLengthPx = featureCoordinates.featureLengthPx;
	}

	var featureLabelId = labelPrefix + '_' + feature.id + '_' + feature.start + '_' + feature.end;
	
	var chrFeature = document.createElement("div");
	var eChrFeature = new YAHOO.util.Element(chrFeature);
	eChrFeature.set('id', featureLabelId);
	//eChrFeature.set('title', featureLabel.id);
	eChrFeature.setStyle('position', 'absolute');
	eChrFeature.setStyle('top', YAHOO.dasBrowser.util.addPxSuffix(annotationTop));
	//CvContSAnnot_chromosome1_s0_featureName
	

	eChrFeature.setStyle('left', YAHOO.dasBrowser.util.addPxSuffix(featureCoordinates.featureStartPx));
	eChrFeature.setStyle('width', YAHOO.dasBrowser.util.addPxSuffix(featureLengthPx));
	
	if(annotationSource.representation == "chart"){
		eChrFeature.setStyle('height', YAHOO.dasBrowser.util.addPxSuffix(annotationHeight));
		if(annotationSource.align == "bottom"){
			eChrFeature.setStyle('border-bottom', '1px solid #000000');
			eChrFeature.setStyle('background-color', '#'+ annotationSource.color);
			eChrFeature.setStyle('opacity', 0.7);
		}else{
			//eChrFeature.setStyle('border-top', '1px solid #'+ annotationSource.color);
			eChrFeature.setStyle('border-top', '1px solid #000000');
			eChrFeature.setStyle('background-color', '#'+ annotationSource.color);
			eChrFeature.setStyle('opacity', 0.7);
		}
	} else if(annotationSource.representation == "line"){
		eChrFeature.setStyle('height', YAHOO.dasBrowser.util.addPxSuffix(0));
		if(annotationSource.align == "bottom"){
			eChrFeature.setStyle('border-bottom', '2px solid #'+ annotationSource.color);
			//eChrFeature.setStyle('background-color', '#'+ annotationSource.color);
			eChrFeature.setStyle('opacity', 0.7);
		}else{
			eChrFeature.setStyle('border-top', '2px solid #'+ annotationSource.color);
			//eChrFeature.setStyle('background-color', '#'+ annotationSource.color);
			eChrFeature.setStyle('opacity', 0.7);
		}
	}
	if(featureLengthPx <= 2 && annotationSource.representation == "line"){
		var featureBorder = 2;
		var chrFeatureBg = document.createElement("div");
		var eChrFeatureBg = new YAHOO.util.Element(chrFeatureBg);
		eChrFeatureBg.set('id', featureLabelId + "_bg");
		//eChrFeature.set('title', featureLabel.id);
		eChrFeatureBg.setStyle('position', 'absolute');
		eChrFeatureBg.setStyle('top', YAHOO.dasBrowser.util.addPxSuffix(annotationTop-featureBorder));
		eChrFeatureBg.setStyle('left', YAHOO.dasBrowser.util.addPxSuffix(featureCoordinates.featureStartPx-featureBorder));
		eChrFeatureBg.setStyle('width', YAHOO.dasBrowser.util.addPxSuffix(featureLengthPx+(2*featureBorder)));
		eChrFeatureBg.setStyle('height', YAHOO.dasBrowser.util.addPxSuffix(2+(2*featureBorder)));
		eChrFeatureBg.setStyle('opacity', 0.2);
		eChrFeatureBg.setStyle('background-color', '#666666');
		eChrFeatureBg.setStyle('z-index', '-1');
		eChrContainer.appendChild(eChrFeatureBg);
	}
	
	eChrContainer.appendChild(eChrFeature);
	//YAHOO.dasBrowser.genome.karyotypeStructure.karyotype.setAnnotationTooltip(featureLabelId, null, 0, labelPrefix);

	feature.chromosomeId = chrId;
	feature.sourceName = annotationSource.name;
	YAHOO.util.Event.addListener(featureLabelId, "click", simpleAnnotationClickCallback, feature);
	YAHOO.util.Event.addListener(featureLabelId, "mouseover", simpleAnnotationMouseoverCallback, feature);
	YAHOO.util.Event.addListener(featureLabelId, "mouseout", simpleAnnotationMouseoutCallback, feature);
}

function simpleAnnotationMouseoutCallback(e, feature){
	var toolTipIdName = this.id+'_tt2';
	var toolTipPosition = YAHOO.util.Dom.getXY(toolTipIdName);
	if(toolTipPosition){
		YAHOO.dasBrowser.yuiContainer.overlay[toolTipIdName].hide();
	}
}

function simpleAnnotationMouseoverCallback(e, feature){
	var eContainer = new YAHOO.util.Element("clientContainer");
	var featurePosition = YAHOO.util.Dom.getXY(this.id);
	var toolTipIdName = this.id+'_tt2';
	var toolTipPosition = YAHOO.util.Dom.getXY(toolTipIdName);

	if(toolTipPosition){
		YAHOO.dasBrowser.yuiContainer.overlay[toolTipIdName].show();
	} else {
		var tooltipPanel = document.createElement("div");
		var eTooltipPanel = new YAHOO.util.Element(tooltipPanel);
		eTooltipPanel.set('id', toolTipIdName);
		eTooltipPanel.addClass('dasbrowser-tt');
		
		var tooltipHead = document.createElement("div");
		var eTooltipHead = new YAHOO.util.Element(tooltipHead);
		eTooltipHead.addClass('hd');
		eTooltipHead.appendChild(document.createTextNode(feature.id));
		eTooltipPanel.appendChild(eTooltipHead);
		
		if (YAHOO.lang.isNumber(feature.score) && feature.score != 0) {
			var tooltipBody = document.createElement("div");
			var eTooltipBody = new YAHOO.util.Element(tooltipBody);
			eTooltipBody.addClass('bd');
			eTooltipBody.appendChild(document.createTextNode(feature.score));
			eTooltipPanel.appendChild(eTooltipBody);
		}
	
		//var tooltipFoot = document.createElement("div");
		//var eTooltipFoot = new YAHOO.util.Element(tooltipFoot);
		//eTooltipFoot.addClass('ft');
		//eTooltipFoot.appendChild(document.createTextNode("Source name"));
		//eTooltipPanel.appendChild(tooltipFoot);
		
		eContainer.appendChild(eTooltipPanel);
		
		var newFeaturePosition = [featurePosition[0]+7,featurePosition[1]+20];
		YAHOO.dasBrowser.yuiContainer.overlay[toolTipIdName] = new YAHOO.widget.Overlay(toolTipIdName, {xy:newFeaturePosition, zIndex:4});
		YAHOO.dasBrowser.yuiContainer.overlay[toolTipIdName].render();
	}
}


function simpleAnnotationClickCallback(e, feature){
	//console.log(feature.chromosomeId);
	//var eContainer = new YAHOO.util.Element(this.parentNode.id);
	var eContainer = new YAHOO.util.Element("clientContainer");
	var featurePosition = YAHOO.util.Dom.getXY(this.id); 
	var toolTipIdName = this.id+'_tt1';
	var toolTipPosition = YAHOO.util.Dom.getXY(toolTipIdName);
	var featureTitle = feature.id;
	if(feature.label.length > 0){
		featureTitle = feature.label;
	}

	if(toolTipPosition){
		YAHOO.dasBrowser.yuiContainer.panel[toolTipIdName].show();
		//var eTooltipPanelContainer = new YAHOO.util.Element(toolTipIdName+'_c');
		//eTooltipPanelContainer.setStyle('visibility','visible');
	} else {
		var tooltipPanel = document.createElement("div");
		var eTooltipPanel = new YAHOO.util.Element(tooltipPanel);
		eTooltipPanel.set('id', toolTipIdName);
		
		var tooltipHead = document.createElement("div");
		var eTooltipHead = new YAHOO.util.Element(tooltipHead);
		eTooltipHead.addClass('hd');
		eTooltipHead.appendChild(document.createTextNode(featureTitle));
		
		var tooltipBody = document.createElement("div");
		var eTooltipBody = new YAHOO.util.Element(tooltipBody);
		eTooltipBody.addClass('bd');
		
		var tooltipFoot = document.createElement("div");
		var eTooltipFoot = new YAHOO.util.Element(tooltipFoot);
		eTooltipFoot.addClass('ft');
		
		var featureId = ['id', 'label', 'typeId', 'typeName', 'typeReference', 'typeCategory', 'start', 'end', 'length', 'methodId', 'methodName', 'score', 'orientation', 'phase', 'linkUrl', 'groupId', 'note'];
		var featureTitles = ['Id', 'Label', 'Type Id', 'Type Name', 'Type Reference', 'Category', 'Start', 'End', 'Length', 'Method Id', 'Method Name', 'Score', 'Orientation', 'Phase', 'Link', 'Group Id', 'Note'];
		
		var showTypeName = true;
		var showLabel = true;
		var showMethodName = true;
		for (var j = 0; j < featureId.length; j++) {
			var nodeContent = feature[featureId[j]];
			
			if(featureId[j] == 'typeId') {
				if(feature['typeId'] == feature['typeName']){
					showTypeName = false;
				}
			}
			if (featureId[j] == 'typeName' && showTypeName == false) {
				nodeContent = "";
			}
			
			if(featureId[j] == 'id') {
				if(feature['id'] == feature['label']){
					showLabel = false;
				}
			}
			if (featureId[j] == 'label' && showLabel == false) {
				nodeContent = "";
			}
			
			if (featureId[j] == 'score' && showLabel == false) {
				nodeContent = "";
			}
			if(featureId[j] == 'methodId') {
				if(feature['methodId'] == feature['methodName']){
					showMethodName = false;
				}
			}
			if (featureId[j] == 'methodName' && showMethodName == false) {
				nodeContent = "";
			}
			
			if (featureId[j] == 'note') {
				var noteStart = feature[featureId[j]].substr(0,9);
				if(noteStart == "sequence:"){
					var noteContent = feature[featureId[j]].substr(9);
					
					var featureInfo = new Object();
					featureInfo.chromosomeId = feature['id'];
					featureInfo.start = 1;
					featureInfo.end = noteContent.length;
					featureInfo.featureSequence = noteContent;
					
					var featureSequenceLink = document.createElement("a");
					var eFeatureSequenceLink = new YAHOO.util.Element(featureSequenceLink);
					eFeatureSequenceLink.addListener('click', sequenceLinkClickCallback, featureInfo);
					eFeatureSequenceLink.appendChild(document.createTextNode("Display feature sequence"));
					eTooltipFoot.appendChild(eFeatureSequenceLink);
					eTooltipFoot.appendChild(document.createElement("br"));
					nodeContent = "";			
				}
			}
			
			if(nodeContent != ""){
				var title = document.createTextNode(featureTitles[j] + ': ');
				var titleBold = document.createElement("b");
				titleBold.appendChild(title);
				var value = document.createTextNode(nodeContent);
				var br = document.createElement("br");
				eTooltipBody.appendChild(titleBold);
				if (featureId[j] == 'linkUrl') {
					var featureLink = document.createElement("a");
					var eFeatureLink = new YAHOO.util.Element(featureLink);
					if(feature['linkText'] != ''){
						value = document.createTextNode(feature['linkText']);
					}
					eFeatureLink.appendChild(value);
					eFeatureLink.set('href', nodeContent); 
					eFeatureLink.set('target', "_blank"); 
					eTooltipBody.appendChild(eFeatureLink);
				} else {
					eTooltipBody.appendChild(value);
				}
				eTooltipBody.appendChild(br);
			}
		}
		
		var sequenceLength =feature.end - feature.start;
		if(sequenceLength < 100000){
			var sequenceInfo = new Object();
			sequenceInfo.chromosomeId = feature.chromosomeId;
			sequenceInfo.start = feature.start;
			sequenceInfo.end = feature.end;
			sequenceInfo.featureSequence = null;
			var sequenceLink = document.createElement("a");
			var eSequenceLink = new YAHOO.util.Element(sequenceLink);
			eSequenceLink.addListener('click', sequenceLinkClickCallback, sequenceInfo);
			eSequenceLink.appendChild(document.createTextNode("Display genome sequence"));
			
			eTooltipFoot.appendChild(eSequenceLink);
			eTooltipFoot.appendChild(document.createElement("br"));
		}
		
		/* decipher */
		if(feature.sourceName.toLowerCase().indexOf("decipher")!= -1){
			//var decipherLink = document.createElement("a");
			//var eDecipherLink = new YAHOO.util.Element(decipherLink);
			//eDecipherLink.set('href', "https://decipher.sanger.ac.uk/application/patient/"+feature.label);
			//eDecipherLink.set('target', '_decipher');
			//eDecipherLink.appendChild(document.createTextNode("Link to decipher patient "+feature.label));
			//eTooltipFoot.appendChild(eDecipherLink);
			//eTooltipFoot.appendChild(document.createElement("br"));
			
			var featureInfo = new Object();
			featureInfo.chromosomeId = feature.chromosomeId;
			featureInfo.start = feature.start;
			featureInfo.end = feature.end;
			
			var decipherZoom = document.createElement("a");
			var eDecipherZoom = new YAHOO.util.Element(decipherZoom);
			eDecipherZoom.addListener('click', decipherZoomClickCallback, featureInfo);
			eDecipherZoom.appendChild(document.createTextNode("Zoom feature"));
			eDecipherZoom.addClass("kdLink");
			
			eTooltipFoot.appendChild(eDecipherZoom);
			eTooltipFoot.appendChild(document.createElement("br"));
		}
		
		/* Toronto link */
		if(feature.sourceName.toLowerCase().indexOf("toronto")!= -1 || feature.sourceName.toLowerCase().indexOf("database of genomic variants")!= -1){
			//var torontoLink = document.createElement("a");
			//var eTorontoLink = new YAHOO.util.Element(torontoLink);
			//eTorontoLink.set('href', "http://projects.tcag.ca/cgi-bin/variation/xview?source=hg18&view=variation&id="+feature.label);
			//eTorontoLink.set('target', '_decipher');
			//eTorontoLink.appendChild(document.createTextNode("Link to "+feature.label));
			//eTooltipFoot.appendChild(eTorontoLink);
			//eTooltipFoot.appendChild(document.createElement("br"));
		}
		
		
		eTooltipPanel.appendChild(eTooltipHead);
		eTooltipPanel.appendChild(eTooltipBody);
		eTooltipPanel.appendChild(eTooltipFoot);
		eContainer.appendChild(eTooltipPanel);
		
		YAHOO.dasBrowser.yuiContainer.panel[toolTipIdName] = new YAHOO.widget.Panel(toolTipIdName, {xy:featurePosition, zIndex:4, width: 280});
		YAHOO.dasBrowser.yuiContainer.panel[toolTipIdName].render();
	}
	
}

function sequenceLinkClickCallback(e, selectedSequence){
	//console.log(selectedSequence.chromosomeId +'_'+ selectedSequence.start +'_'+ selectedSequence.end);
	var container = document.getElementById('sequenceView');
	container.innerHTML = "";
	YAHOO.dasBrowser.genome.karyotypeStructure.karyotype.drawSequenceViewStructure(selectedSequence.chromosomeId, selectedSequence.start, selectedSequence.end, selectedSequence.featureSequence);
	// OPEN SEQUENCE VIEW
	YAHOO.dasBrowser.yuiContainer.panel['sequenceView'].show();
}

function decipherZoomClickCallback(e, featureInfo){
			YAHOO.dasBrowser.genome.karyotypeStructure.karyotype.redrawZoom(
				featureInfo.chromosomeId,
				featureInfo.start,
				featureInfo.end
			);
}


YAHOO.dasBrowser.genome.karyotypeStructure.karyotype.setAnnotationTooltip = function(divId, content, delay, parentContainer){
	//var myTooltip = new YAHOO.widget.Tooltip(divId+'_tt3', { context:divId, text:content, showDelay:delay, container:parentContainer });
}











YAHOO.dasBrowser.genome.karyotypeStructure.karyotype.drawChromosomeSimpleAnnotation = function(feature, chrId, labelPrefix, chrPrefix, sourceArrayNumber, featureCoordinates, annotationHeight){
	var arrowLimitPx = YAHOO.dasBrowser.genome.annotations.simpleView.arrowLimitPx;
	//var annotationHeight = YAHOO.dasBrowser.genome.annotations.simpleView.annotationHeight;
	var entryPoints = YAHOO.dasBrowser.genome.karyotypeStructure.entryPoints.allEntryPoints[chrId];
	var annotationSource = YAHOO.dasBrowser.genome.annotations.sources[sourceArrayNumber];
	var sourcePanel = annotationSource.panel;
	var bandLabelPrefix = YAHOO.dasBrowser.genome.karyotypeStructure.karyotype.bandConf.labelPrefix;
	var zoomLabelPrefix = YAHOO.dasBrowser.genome.karyotypeStructure.karyotype.zoomConf.labelPrefix;
	var maxLetterSize = 4.5;

	var eChrContainer = new YAHOO.util.Element(labelPrefix);
	var eChrContainerWidthStyle = eChrContainer.getStyle('width');
	var widthPx = YAHOO.dasBrowser.util.deletePxSuffix(eChrContainerWidthStyle);
	//CvContSAnnot_chromosome1_s0

	if(featureCoordinates.featureLengthPx < 1){
		var featureLengthPx = 1;
	} else {
		var featureLengthPx = featureCoordinates.featureLengthPx;
	}
	
	var featureLabelId = labelPrefix + '_' + feature.id + '_' + feature.start + '_' + feature.end;
	
	var chrFeature = document.createElement("div");
	var eChrFeature = new YAHOO.util.Element(chrFeature);
	eChrFeature.set('id', featureLabelId);
	//eChrFeature.set('title', featureLabel.id);
	eChrFeature.setStyle('position', 'absolute');
	eChrFeature.setStyle('top', '0px');
	//CvContSAnnot_chromosome1_s0_featureName
	
	//var annotationSource = YAHOO.dasBrowser.genome.annotations.sources[sourceArrayNumber];
	var annotationTop = 0;
	if (annotationSource.representation == 'track') {
		if(featureCoordinates.track != null){
			if(chrPrefix == bandLabelPrefix || chrPrefix == zoomLabelPrefix){
				//annotationTop = (annotationHeight+7) * (featureCoordinates.track);
				annotationTop = (annotationHeight+2) * (featureCoordinates.track);
			} else {
				annotationTop = annotationHeight * (featureCoordinates.track);
			}
		}
	}
	
	var annotationColor = '#' + annotationSource.color;
	if(annotationSource.stylesheet == true){
		//console.log(feature.typeId);
		//console.log(annotationSource.stylesheetData.types[feature.typeId].bgcolor);
		if(annotationSource.stylesheetData.types){
			if(annotationSource.stylesheetData.types[feature.typeId]){
				if(annotationSource.stylesheetData.types[feature.typeId].fgcolor.length != 0){
					annotationColor = annotationSource.stylesheetData.types[feature.typeId].fgcolor;
				}
			}
		}
		//console.log("aC"+annotationColor);
	}
	
	
	
	if(featureLengthPx <= arrowLimitPx){
		eChrFeature.setStyle('top', YAHOO.dasBrowser.util.addPxSuffix(annotationTop));
		eChrFeature.setStyle('left', YAHOO.dasBrowser.util.addPxSuffix(featureCoordinates.featureStartPx+(featureLengthPx/2)-2));
		eChrFeature.setStyle('width', '5px');
		eChrFeature.setStyle('height', YAHOO.dasBrowser.util.addPxSuffix(annotationHeight));
		eChrFeature.setStyle('opacity', 0.7);
		eChrFeature.addClass('aColor');
		//eChrFeature.setStyle("backgroundColor", annotationColor);
		eChrFeature.setStyle("backgroundColor", annotationColor);
		if(annotationSource.align == "bottom"){
			//eChrFeature.setStyle('background-image', 'url(img/transArrowUp.png)');
		}else{
			//eChrFeature.setStyle('background-image', 'url(img/transArrowDown.png)');
		}
		
	}else{
		eChrFeature.setStyle('top', YAHOO.dasBrowser.util.addPxSuffix(annotationTop));
		eChrFeature.setStyle('left', YAHOO.dasBrowser.util.addPxSuffix(featureCoordinates.featureStartPx));
		eChrFeature.setStyle('width', YAHOO.dasBrowser.util.addPxSuffix(featureLengthPx));
		eChrFeature.setStyle('height', YAHOO.dasBrowser.util.addPxSuffix(annotationHeight-1));	
		eChrFeature.setStyle('border-top', '1px solid '+ annotationColor);
		eChrFeature.setStyle('background-color', annotationColor);
		eChrFeature.setStyle('opacity', 0.7);
	}
	var chrFeatureBlackCorner = document.createElement("div");
	var eChrFeatureBlackCorner = new YAHOO.util.Element(chrFeatureBlackCorner);
	eChrFeatureBlackCorner.setStyle('width', '2px');
	eChrFeatureBlackCorner.setStyle('height', '2px');
	eChrFeatureBlackCorner.setStyle('background-color', '#000000');
	eChrFeatureBlackCorner.appendChild(document.createTextNode(" "));
	
	eChrFeature.appendChild(eChrFeatureBlackCorner);

	//if (sourcePanel == "zoom" || sourcePanel == "band") {
	if(chrPrefix == YAHOO.dasBrowser.genome.karyotypeStructure.karyotype.bandConf.labelPrefix || chrPrefix == YAHOO.dasBrowser.genome.karyotypeStructure.karyotype.zoomConf.labelPrefix){
			var wordValue = maxLetterSize * feature.id.length;
			if(featureLengthPx>wordValue){
				var featureTitle = feature.id;
				if(feature.label.length > 0){
					featureTitle = feature.label;
				}
				var fontSize = YAHOO.dasBrowser.genome.karyotypeStructure.karyotype.labelFontSizePx-1;
				var eChrContainerLabels = new YAHOO.util.Element(labelPrefix + "_labels");
				var chrFeatureLabel = document.createElement("span");
				var eChrFeatureLabel = new YAHOO.util.Element(chrFeatureLabel);
				eChrFeatureLabel.set('id', featureLabelId + "_label");
				//eChrFeature.set('title', featureLabel.id);
				eChrFeatureLabel.setStyle('position', 'absolute');
				eChrFeatureLabel.setStyle('top', YAHOO.dasBrowser.util.addPxSuffix(annotationTop-annotationHeight));
				eChrFeatureLabel.setStyle('left', YAHOO.dasBrowser.util.addPxSuffix(featureCoordinates.featureStartPx+3));
				eChrFeatureLabel.setStyle('z-index', '1');
				eChrFeatureLabel.addClass('fontSize' + fontSize);
				//eChrFeatureLabel.setStyle('font-style', 'italic');
				eChrFeatureLabel.appendChild(document.createTextNode(featureTitle));
				eChrContainerLabels.appendChild(eChrFeatureLabel);
			}
	}

	eChrContainer.appendChild(eChrFeature);
	feature.chromosomeId = chrId;
	feature.sourceName = annotationSource.name;
	//YAHOO.dasBrowser.genome.karyotypeStructure.karyotype.setAnnotationTooltip(featureLabelId, null, 0);
	YAHOO.util.Event.addListener(featureLabelId, "click", simpleAnnotationClickCallback, feature);
	YAHOO.util.Event.addListener(featureLabelId, "mouseover", simpleAnnotationMouseoverCallback, feature);
	YAHOO.util.Event.addListener(featureLabelId, "mouseout", simpleAnnotationMouseoutCallback, feature);
	
	YAHOO.util.Event.addListener(featureLabelId + "_label", "click", simpleAnnotationClickCallback, feature);
	YAHOO.util.Event.addListener(featureLabelId + "_label", "mouseover", simpleAnnotationMouseoverCallback, feature);
	YAHOO.util.Event.addListener(featureLabelId + "_label", "mouseout", simpleAnnotationMouseoutCallback, feature);
}



